package core.util;
/**
 * json返回对象
 * @author bj
 *
 */
public class AjaxResult {
	
	public static final int SUCCESS_CODE=0;
	public static final int FAIL_CODE=-1;
	public static final String SUCCESS_MSG="操作成功!";
	public static final String FAIL_MSG="操作失败!";
	
	public boolean success;
	public int code;
	public String msg;
	public Object data;

	public AjaxResult() {
		code = SUCCESS_CODE;
		msg = SUCCESS_MSG;
		success = true;
	}

	public AjaxResult(boolean success) {
		this.success = success;
		if (success) {
			code = SUCCESS_CODE;
			msg = SUCCESS_MSG;
		} else {
			code = FAIL_CODE;
			msg = FAIL_MSG;
		}
	}

	public AjaxResult(boolean success, String msg) {
		this.success = success;
		this.msg = msg;
		if (success) {
			code = SUCCESS_CODE;
		} else {
			code = FAIL_CODE;
		}
	}

	public AjaxResult(boolean success, int code, String msg) {
		this.success = success;
		this.msg = msg;
		if (success) {
			this.code = SUCCESS_CODE;
		} else {
			this.code = code;
		}
	}

	public boolean getSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

}
